<!DOCTYPE html>
<html>
<head>
    <title>我的客户</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <link rel="stylesheet" href="${s.base}/mobile/base/css/jquery-weui.css">
    <link rel="stylesheet" href="${s.base}/mobile/base/css/base.css?123456">
    <link rel="stylesheet" href="${s.base}/mobile/base/css/component.css?123456">
    <link rel="stylesheet" href="${s.base}/mobile/base/css/myCustomer.css?11232">
</head>
<body>
<!--搜索框-->
<div class="xyg-comp-search2">
    <div class="xyg-comp-search">
        <div class="xyg-comp-search-left">
            <input type="text" id="searchKey" onchange="search()" placeholder="搜索客户姓名/手机号"/>
        </div>
        <div class="xyg-comp-search-right" data-value="1" id="sxBtn">
            筛选<span class="icon-xia"><svg class="icon" aria-hidden="true"><use xlink:href="#icondownward_searchx"></use></svg></span><span class="icon-shang" style="display:none;"><svg class="icon" aria-hidden="true"><use xlink:href="#iconupward_searchx"></use></svg></span>
        </div>
        <div class="clearBoth"></div>
    </div>
    <div class="xyg-comp-searchkey icon-shang" style="display:none;">
        <div class="xyg-comp-searchkey-item <#if status==''>active</#if>" data-value="">
            全部
        </div>
        <div class="xyg-comp-searchkey-item <#if status=='1'>active</#if>" data-value="1">
            报备成功
        </div>
        <div class="xyg-comp-searchkey-item <#if status=='2'>active</#if>" data-value="2">
            客户到访
        </div>
        <div class="xyg-comp-searchkey-item <#if status=='3'>active</#if>" data-value="3">
            认筹确认
        </div>
        <div class="xyg-comp-searchkey-item <#if status=='4'>active</#if>" data-value="4">
            无效客户
        </div>
        <div class="clearBoth"></div>
    </div>
</div>
<div style="width:100%; height:150px;"></div>
<div class="xyg-content">

</div>

<!--底部菜单开始-->
<div style="width:100%; height:98px;"></div>
<div class="xyg-comp-bottom3">
    <div class="xyg-comp-bottom-item">
        <a href="javascript:goFistPage('${memberId}')">
            <img src="${s.base}/mobile/base/images/icon_menu_1.png"/>
            <div class="xyg-comp-bottom-item-text ">首页</div>
        </a>
    </div>
    <div class="xyg-comp-bottom-item">
        <a href="javascript:goAllCustomerEditPage('${memberId}')">
            <img src="${s.base}/mobile/base/images/icon_menu_2.png"/>
            <div class="xyg-comp-bottom-item-text">推荐</div>
        </a>
    </div>
    <div class="xyg-comp-bottom-item">
        <a href="javascript:goMyPage('${memberId}')">
            <img src="${s.base}/mobile/base/images/icon_menu_3_a.png"/>
            <div class="xyg-comp-bottom-item-text select-text">我的</div>
        </a>
    </div>
    <div class="clearBoth"></div>
</div>
<!--底部菜单结束-->

</body>
<script src="https://res.wx.qq.com/open/js/jweixin-1.3.2.js"></script>
<script src="${s.base}/mobile/base/js/jquery-2.1.4.js"></script>
<script src="${s.base}/mobile/base/js/jquery-weui.js"></script>
<script src="${s.base}/mobile/base/js/swiper.js"></script>
<script src="${s.base}/mobile/base/fonts/iconfont.js?123456"></script>
<script src="${s.base}/mobile/base/js/component.js"></script>
<script src="${s.base}/mobile/base/js/base.js?123456789000"></script>

<!--js分享代码开始-->
<input type="hidden" value="${jSTicketShareResponse.appid}" id="appid" />
<input type="hidden" value="${jSTicketShareResponse.fxTitle}" id="fxTitle" />
<input type="hidden" value="${jSTicketShareResponse.fxImgUrl}" id="fxImgUrl" />
<input type="hidden" value="${jSTicketShareResponse.fxDesc}" id="fxDesc" />
<input type="hidden" value="${jSTicketShareResponse.fxUrl}" id="fxUrl" />
<input type="hidden" value="${jSTicketShareResponse.nonceStr}" id="nonceStr" />
<input type="hidden" value="${jSTicketShareResponse.timestamp}" id="timestamp" />
<input type="hidden" value="${jSTicketShareResponse.signature}" id="signature" />
<script src="${s.base}/mobile/base/js/share.js"></script>
<script type="text/javascript">
    initXygDpi();
    var status = '${status}';
    var memberId = '${memberId}';
    var searchKey = '';
    $(document).ready(function (e) {
        initDate();
    });

    function initDate() {
        $("#sxBtn").bind("click",function(){
            if("1"==$("#sxBtn").attr("data-value")){
                $("#sxBtn").attr("data-value","2");
                $(".icon-xia").hide();
                $(".icon-shang").show();
            }else{
                $("#sxBtn").attr("data-value","1");
                $(".icon-xia").show();
                $(".icon-shang").hide();
            }
        });
        $(".xyg-comp-searchkey-item").bind("click",function(){
            $(".xyg-comp-searchkey-item").removeClass("active");
            // 分页查看
            $(this).addClass("active");
            if("1"==$("#sxBtn").attr("data-value")){
                $("#sxBtn").attr("data-value","2");
                $(".icon-xia").hide();
                $(".icon-shang").show();
            }else{
                $("#sxBtn").attr("data-value","1");
                $(".icon-xia").show();
                $(".icon-shang").hide();
            }

            status = $(this).attr("data-value");
            pageNum = 1;
            $(".xyg-content").html("");
            if(isDestroy){
                initContentNum();
            }else{
                sendPost();
            }
        });
        initContentNum();
    }

    function search(){
        searchKey = $("#searchKey").val();
        pageNum = 1;
        $(".xyg-content").html("");
        if(isDestroy){
            initContentNum();
        }else{
            sendPost();
        }
    }

    var pageNum = 0;
    var pageSize = 5;
    var loading = false;  //状态标记
    var isDestroy = false;  //状态标记
    /**
     * 初始化内容页面信息
     * @param cityId
     */
    function initContentNum() {
        isDestroy = false;
        $(document.body).infinite().on("infinite", function () {
            if (loading) return;
            loading = true;
            sendPost();
        });
        sendPost();
    }

    function sendPost() {
        pageNum++;
        $.fn.postMethodAll("/weChat/hostReport/page",{'pageNum':pageNum,'pageSize':pageSize,'reportState':status,'memberId':memberId,'searchKey':searchKey},function (result) {
            if (result.data != null && result.data.length > 0) {
                result.data.forEach(function (item,key,mapObj) {
                    // 报备状态：1、报备成功，2、客户到访，3、认筹确认，4、无效客户
                    var stateName="报备成功";
                    if(item.reportState=="2"){
                        stateName="客户到访";
                    }else if(item.reportState=="3"){
                        stateName="认筹确认";
                    }else if(item.reportState=="4"){
                        stateName="无效客户";
                    }
                    var str='<div class="xyg-content-item">\
                        <div class="xyg-content-item-left">\
                        <img src="'+item.memberHeadImage+'"/>\
                        </div>\
                        <div class="xyg-content-item-right">\
                        <div class="xyg-content-item-line font-base4-size-bold color3">\
                        '+item.name+'\
                        <div class="xyg-content-item-line-type">'+stateName+'</div>\
                        </div>\
                        <div class="xyg-content-item-line font-base4-size color3">\
                        手机号码&nbsp;&nbsp;'+item.phone+'\
                    </div>\
                    <div class="xyg-content-item-line font-base4-size color3">\
                        推荐楼盘&nbsp;&nbsp;'+item.itemName+'\
                    </div>\
                    <div class="xyg-content-item-line font-base4-size color3">\
                        推荐时间&nbsp;&nbsp;'+item.createTimeStr+'\
                    </div>\
                    </div>\
                    <div class="clearBoth"></div>\
                        </div>';
                    $(".xyg-content").append(str);
                });
                loading = false;
                if (!result.hasNextPage) {
                    $(document.body).destroyInfinite();
                    isDestroy=true;
                }
            } else {
                $(document.body).destroyInfinite();
                isDestroy=true;
                /*if(result.count==0){
                    $(".xyg-content").html('<div class="xyg-zwyj">暂无客户</div>');
                }*/
            }
            if(result.count<=0){
                $(".xyg-content").html('<div style="width: 100%; height: auto; line-height: 50px; text-align: center; margin-top: 150px; color: #0A0A0A; font-size: 32px;">'+
                    '<img src="${s.base}/mobile/base/images/no.png" style="width: 350px; height: auto; margin: 10px auto;"/>'+
                    '暂无数据</div>');
            }
        });
    }
</script>

</html>

